<template>
  <div class="page">
    <div class="page-breadcrumb">
      <el-breadcrumb class="strong" separator="/">
        <el-breadcrumb-item :to="{ path: '/work/auditList' }">审核列表</el-breadcrumb-item>
        <el-breadcrumb-item>工单详情</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    
    <v-pageSearch>
      <el-form :inline="true">
        <el-row>
          <el-col :span="8">
            <el-form-item>
              <el-tag :type="statue | statusFilterType">{{statue | statusFilter}}</el-tag>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工单日期：">
              <h4>{{date}}</h4>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工单人员：">
              <h4>{{auditor}}</h4>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </v-pageSearch>

    <el-collapse v-model="activeNames" v-for="data in itemList" :key="data.index">
      <el-collapse-item :title="'项目名称：' + data.title" :name="data.index">
        <div>{{data.content}}</div>
      </el-collapse-item>
    </el-collapse>
    
    <el-row :gutter="20">
      <el-col :span="12" :offset="6">
        <el-form ref="form" :model="form" label-width="150px" style="margin-top:20px;">
          <el-form-item label="审核状态">
            <el-radio-group v-model="form.status" @change="statusChange(form.status)">
              <el-radio-button label="0">未审核</el-radio-button>
              <el-radio-button label="1">审核通过</el-radio-button>
              <el-radio-button label="2">审核不通过</el-radio-button>
            </el-radio-group>
            <span style="color:red; font-size:12px;"> 注:审核后将无法修改，请谨慎审核！！</span>
          </el-form-item>
          <el-form-item label="审核未通过原因">
            <el-input :disabled="disabled" type="textarea" :rows="5" style="width:600px;" v-model="form.reason"></el-input>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>

    <el-row type="flex" justify="center">
      <el-col :span="3">
        <el-button type="success" @click="onSubmit('order')"><i class="fa fa-check fa-lg"></i> &nbsp;提交</el-button>
      </el-col>
      <el-col :span="3">
        <v-pageBack align='right' style="padding:0;">
        </v-pageBack>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  export default {
    data() { 
      return {
        date: '',
        auditor: '',  
        itemList:[],
        form: {
          status: '0',
          reason: ''
        },
        disabled: true
      };
    },
    filters: {
      statusFilter(statue) {
        const statusMap = ['审核通过','已提醒','未审核','审核不通过']
        return statusMap[statue]
      },
      statusFilterType(statue) {
        const statusMapType = ['primary','success','danger','error']
        return statusMapType[statue]
      }
    },
    computed: {
      activeNames: {
        get: function () {
          let arr = []
          this.itemList.forEach(function (item, index, array) {
            arr.push(index+'')
          });
          return arr;
        },
        set: function (v) {
          let arr = []
          this.itemList.forEach(function (item, index, array) {
            arr.push(index+'')
          });
          return arr;
        }
      }
    },
    methods: {
        // 接收路由参数数据
        fetchData () {
            let objArr = this.$route.query.obj.split(',');
            this.date = objArr[1];
            this.auditor = objArr[2];
            this.statue = objArr[3];
            console.log(objArr)
            this.itemList =  [
                {
                  title:'圆通项目',
                  index:'0',
                  content:'1313要做就要做到最好'
                },{
                  title:'韵达项目',
                  index:'1',
                  content:'豫章故郡，洪都新府。星分翼轸，地接衡庐。襟三江而带五湖，控蛮荆而引瓯越。物华天宝，龙光射牛斗之墟；人杰地灵，徐孺下陈蕃之榻。雄州雾列，俊采星驰。台隍枕夷夏之交，宾主尽东南之美。都督阎公之雅望，棨戟遥临；宇文新州之懿范，襜帷暂驻。十旬休假，胜友如云；千里逢迎，高朋满座。腾蛟起凤，孟学士之词宗；紫电青霜，王将军之武库。家君作宰，路出名区；童子何知，躬逢胜饯。'+
                          '时维九月，序属三秋。潦水尽而寒潭清，烟光凝而暮山紫。俨骖騑于上路，访风景于崇阿；临帝子之长洲，得天人之旧馆。层峦耸翠，上出重霄；飞阁流丹，下临无地。鹤汀凫渚，穷岛屿之萦回；桂殿兰宫，即冈峦之体势。'
                }
            ]
        },
        statusChange (value){
          if(value == '2'){
            this.disabled = false;
          }else{
            this.disabled = true;
          }
        }
    },
    created() {
        this.fetchData()
    },
    mounted() {
        
    }
  }
</script>
<style scoped>

</style>
